package com.xiake.controller;

import com.xiake.pojo.Headline;
import com.xiake.service.HeadlineService;
import com.xiake.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("headline")
@CrossOrigin
public class HeadlineController {
    @Autowired
    HeadlineService headlineService;
    @PostMapping("publish")
    public Result publish(@RequestBody Headline headline,@RequestHeader String token){
       Result result= headlineService.publish(headline,token);
       return result;
    }
    @PostMapping("findHeadlineByHid")
    public Result findHeadlineByHid(Integer hid){
        Result result=headlineService.findHeadlineByHid(hid);
        return result;
    }

    @PostMapping("update")
    public Result update(@RequestBody Headline headline){
        Result result=headlineService.updateData(headline);
        return result;
    }

    @PostMapping("removeByHid")
    public Result removeByHid(Integer hid){
        //因为没有其它业务需求，直接调业务层删除.注意是逻辑删除，便于后期回收
        headlineService.removeById(hid);
        return Result.ok(null);
    }

}
